﻿using SQLite;
using System.ComponentModel.DataAnnotations.Schema;
using ColumnAttribute = SQLite.ColumnAttribute;
using TableAttribute = SQLite.TableAttribute;
namespace DailyPoetryM.Models;

//添加依赖包：sqlite-net-pcl
//poetry类和数据库表建立映射关系:  [Column("id")]
//用[Ignore]代表不需要映射

[Table("works")]
public class Poetry
{
    [Column("id")]
    public int Id { get; set; }
    [Column("name")]
    public string Name { get; set; } = string.Empty;
    [Column("author_name")]
    public string Author { get; set; } = string.Empty;
    [Column("dynasty")]
    public string Dynasty { get; set; } = string.Empty;
    [Column("content")]
    public string Content { get; set; } = string.Empty;
    //预览:根据正文的第一句话：用句号。切开split的第【0】个部分

    private string? _snippet;

    [Ignore]
    public string Snippet => _snippet ??= Content.Split('。')[0];
}